/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 *
 * @author spthanh
 */
public class Procedure_Example1 {
    public static void main(String[] args){
        try{
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks", "sa", "123");

            String query = "CREATE Procedure proc_GetEmpl " +
                           " AS" +
                           "    BEGIN" +
                            "         SELECT EmployeeID , LoginID, Title, ManagerID , Gender , VacationHours " +
                            "         FROM HumanResources.Employee " +
                           "    END ";

            Statement stmt = con.createStatement();
            stmt.executeUpdate(query);


        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
}
